import java.sql.Connection;
import java.sql.Statement;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Connection connection = DbUtil.getConnection("root", "123123");
        Statement statement = DbUtil.getStatement(connection);
        try{
            Scanner in=new Scanner(System.in);
            System.out.println("课名");
            String subjectname=in.next();
            System.out.println("课时");
            String classhour=in.next();
            System.out.println("年级");
            String gradeid=in.next();
            String sql="INSERT INTO `s_subject`(`subjectname`,`classhour`,`gradeid`) VALUES ('" + subjectname + "'," + classhour + "," + gradeid + ");";
            int i = statement.executeUpdate(sql);
            if (i == 0) {
                System.out.println("添加失败");
                return;
            }
            System.out.println("添加成功");
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            DbUtil.setClose(connection, statement);
        }
    }
}
